package com.zh.note.demo.juc;

import org.assertj.core.util.Lists;

import java.util.List;
import java.util.function.Supplier;

/**
 * @Author: zhanghuan
 * @date: 2023/9/15 14:22
 * @description: create it
 */
public class ThreadLocalDemo2 {
    private List<String> list = Lists.newArrayList();
    public static final ThreadLocal<ThreadLocalDemo2> threadLocal = ThreadLocal.withInitial(new Supplier<ThreadLocalDemo2>() {
        @Override
        public ThreadLocalDemo2 get() {
            return new ThreadLocalDemo2();
        }
    });

    public static void add(String message) {
        threadLocal.get().list.add(message);
    }

}
